package thread;

import java.io.File;
import java.util.Scanner;

public class Test04_FileCopy {

	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);
		while(true){
			System.out.println("1.파일복사 2.디렉토리크기 3.종료");
			int n = scan.nextInt();
			if(n==1){
				new CopyThread().start();
			}else if (n==2){
				fileSize();
			}else{
				break;
			}
			
		}
		
	}
	public static void fileSize() {
		File f = new File("C:\\workspace\\1403");
		long len = getLen(f);
		System.out.println("디렉토리크기:"+len+"bytes");
		
   }
	public static long getLen(File f){
		File list[] = f.listFiles();
		long len = 0;
		for(int i=0; i<list.length; i++){
			if(list[i].isFile()){
				len+=list[i].length();
				
			}else {
				len+=getLen(list[i]);
			}
		}
		return len;
	}
 }

